#!/usr/bin/env python

from collections import OrderedDict

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.lines as lines

from matplotlib.ticker import MultipleLocator, FormatStrFormatter

linestyles = OrderedDict(
    [('solid',               (0, ())),
     ('loosely dotted',      (0, (1, 10))),
     ('dotted',              (0, (1, 5))),
     ('densely dotted',      (0, (1, 1))),

     ('loosely dashed',      (0, (5, 10))),
     ('dashed',              (0, (5, 5))),
     ('densely dashed',      (0, (5, 1))),

     ('loosely dashdotted',  (0, (10, 4, 2, 4))),
     ('dashdotted',          (0, (3, 5, 1, 5))),
     ('densely dashdotted',  (0, (8, 1, 2, 1))),

     ('densely dashdashdotted',  (0, (8, 1, 8, 1, 2, 1))),
     ('loosely dashdashdotted',  (0, (10, 4, 10, 4, 2, 4))),

     ('loosely dashdotdotted', (0, (10, 4, 2, 4, 2, 4))),
     ('dashdotdotted',         (0, (3, 5, 1, 5, 1, 5))),
     ('densely dashdotdotted', (0, (8, 1, 2, 1, 2, 1)))])

#majorLocator = MultipleLocator(20)
majorFormatter = FormatStrFormatter('%d')
majorFormatter = FormatStrFormatter('%.1f')
majorFormatter = FormatStrFormatter('%.1e')
#minorLocator = MultipleLocator(5)

#plt.rc('text', usetex=True)
#plt.rc('font', family='serif')

fig = plt.figure(figsize=(8,6))
fig.subplots_adjust(bottom=0.12,left=0.16, right=0.97,top=0.95)

ax = fig.add_subplot(111, axisbg='w')
data1 = np.loadtxt('u100.dat');
xdata1 = data1[:,0]
ydata1 = data1[:,1]
#avgCf = np.arange(len(ydata), dtype=np.float64);
#plt.cla()
line1, = plt.plot(xdata1, ydata1, 'r', lw=2.0, label=r'$Re=100$', linestyle=linestyles['loosely dashdashdotted'])

data2 = np.loadtxt('u80.dat');
xdata2 = data2[:,0]
ydata2 = data2[:,1]
line2, = plt.plot(xdata2, ydata2, 'b',markevery=1, lw=2.0,label=r'$Re=80$', linestyle=linestyles['loosely dashdotdotted'])

data3 = np.loadtxt('u60.dat');
xdata3 = data3[:,0]
ydata3 = data3[:,1]
line3, = plt.plot(xdata3, ydata3, 'g',markevery=1,lw=2.0,label=r'$Re=60$', linestyle=linestyles['loosely dashdotted'])


xdata4, ydata4 = np.linspace(0, 3, 10), np.zeros(10)
line4, = plt.plot(xdata4, ydata4, 'k',markevery=1,lw=1.0, linestyle=linestyles['dashed'])

#ax.grid(True)
ax.set_xlabel(r'$x$', fontsize=30)
ax.set_ylabel(r'$u$', fontsize=30)
ax.set_xlim(0,3)
ax.set_ylim(-0.03,0.03)
plt.setp(ax.get_xticklabels(), fontsize=20);
plt.setp(ax.get_yticklabels(), fontsize=20);

#ax.xaxis.set_major_locator(majorLocator)
#ax.xaxis.set_major_formatter(majorFormatter)

# for the minor ticks, use no labels; default NullFormatter
#ax.xaxis.set_minor_locator(minorLocator)
#ax.text(1, 1.6, tex, fontsize=20, va='bottom')

#line2, = plt.plot(xdata, ydata, label='Instant')
plt.legend(loc=0,fontsize=18)

plt.savefig('./circularCylinderU.eps')
plt.savefig('./circularCylinderU.png')
plt.show()


